package com.lepu.app.fun.health.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class BeanDurg implements Serializable {
	private static final long serialVersionUID = 1L;

	public ArrayList<DurgStore> ListInfo;
	public ArrayList<TopDurg> OnLineMedicineList;

	public static BeanDurg parseJsonData(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			// JSONObject obj2 = obj1.getJSONObject("DetailInfo");

			result = obj1.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		BeanDurg item = gson.fromJson(result, new TypeToken<BeanDurg>() {
		}.getType());
		
		for(int i=0; i<item.OnLineMedicineList.size(); i++){
			item.OnLineMedicineList.get(i).ImgUrls = (List<String>) Arrays.asList(item.OnLineMedicineList.get(i).ImgUrl.split("\\|"));
		}
		
		return item;
	}

	public class DurgStore implements Serializable {
		private static final long serialVersionUID = 1L;
		
		public String InstitutionID;
		public String InstitutionName;
		public String Address;
		public String City; //服务器不返回
		public String Distance;
		public double Longitude;
		public double Latitude;

		public ArrayList<Durg> MedicineList;
	}

	public class Durg implements Serializable{
		private static final long serialVersionUID = 1L;
		public String MedicineID;
		public String GenericName;
		public String Price;
		public String ImgUrl;
		public List<String> ImgUrls; // 图片集合
	}

	public static class TopDurg implements Serializable{
		private static final long serialVersionUID = 1L;
		public String MedicineID;
		public String GenericName;
		public String Price;
		public String ImgUrl;
		public List<String> ImgUrls; // 图片集合
	}
	
}
